/**
 * Author(s): xuming.Wong <xuming.Wong@gmail.com>
 */

#ifndef __GAME_OBJECT_MANAGER_H__
#define __GAME_OBJECT_MANAGER_H__

#include "NgPrerequisites.h"

#include "GameObject.h"
#include "MeshData.h"

namespace PQEngine
{
	class SceneObject;
	class QueryFlags
	{
	public:
		static const Ogre::uint QUERYFLAG_WIDGET = 1;
		static const Ogre::uint QUERYFLAG_MOVABLE = 2;
	};

	//this class manager all game object,will used by sceneobject
	//NOW Obsolete(Not used now).
	class GameObjectManager
	{
	public:	
		GameObjectManager(SceneObject* sceneObject);

		void createDefaultGameObjects();
		void loadGameObjects();
		
		GameObject* getObject(Ogre::Ray mouseRay);//is really selected is tested in this function

		GameObject* getRootGameObject();
		GameObject* selectObject(int x,int y);

		/*Get game object by ray start at screen position.
		@param x Screen position X
		@param y Screen position Y
		*/
		GameObject* getObject(int x,int y);

		void deleteGameObject();
		

		GameObject* getSelectedObject();

		void	parentTo(GameObject* child,GameObject* parent);
		
		void update(float deltaT);
		
	private:
		SceneObject* _sceneObject;
		Ogre::SceneManager* _sceneMgr;

		Ogre::SceneNode* _rootNode;
		Ogre::RaySceneQuery* _raySceneQuery;

		GameObject* _selectedObject;//current selected game object
		
		MeshData* _selectMeshData;//used load selected mesh and test selection
		Ogre::uint _command;
		bool _maxFrameObject;//framObject Mode
	};
}
#endif
